<?php 
/**
 *   Joomdiet - components/views/recipesearch/tmpl/default.php
 *   Author: Juan Dapena Paz (juan@bittingbits.com)
 *   Copyright (C) 2010 Bitting Bits S.L.
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
defined('_JEXEC') or die('Restricted access'); ?>
<div id="joomdiet_container">
<h1><?php echo JText::_('COM_JOOMDIET_RECIPE_SEARCH_TITLE'); ?></h1>
<form action="index.php?option=com_joomdiet&task=submitsearchrecipe" method="post" name="joomdietform">
    <div id="recipesearch-info">
        <b><?php echo JText::_('COM_JOOMDIET_SEARCHING')?></b>
        <ol type="1">
            <li><?php echo JText::_('COM_JOOMDIET_RECIPE_HELP'); ?></li>
            <?php if (!$this->advanced) { ?>
                </ol><p><?php echo JText::_('COM_JOOMDIET_ADVANCED_SEARCH_HELP'); ?></p>
            <?php } else { ?>
                <li><?php echo JText::_('COM_JOOMDIET_RECIPE_CATEGORY_HELP'); ?></li>
                <li><?php echo JText::_('COM_JOOMDIET_RECIPE_SUBCATEGORY_HELP'); ?></li>
            </ol>
            <?php } ?>
    </div>
    <div id="recipesearch-panel">
        <table width="60%">
            <tr>
                <td width="50%" align="right"><label for="recipe_name"><b><?php echo JText::_('COM_JOOMDIET_RECIPE'); ?>:</b></label></td>
                <td width="50%"><input style="width: 100%;" type="text" name="recipe_name" id="recipe_name" value="" /></td>
            <tr/>
            <?php if ($this->advanced) { ?>
                <tr>
                    <td width="50%" align="right"><label for="recipe_category"><b><?php echo JText::_('COM_JOOMDIET_RECIPE_CATEGORY'); ?>:</b></label></td>
                    <td width="50%">
                        <select style="width: 100%;" type="text" name="recipe_category" id="recipe_category" value="<?php echo $this->categoryid; ?>" onchange="window.location.href='index.php?option=com_joomdiet&task=recipesearch&advanced=true&recipe_category='+value;">
                            <option value=0><?php echo JText::_('COM_JOOMDIET_ALL'); ?></option>
                            <?php foreach($this->categories as $category) { ?>
                                <option value="<?php echo $category->id; ?>" <?php if ($this->categoryid and ($this->categoryid == $category->id)) { echo 'selected="selected"';} ?>>
                                    <?php echo $category->name; ?>
                                </option>
                            <?php } ?>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td width="50%" align="right"><label for="recipe_subcategory"><b><?php echo JText::_('COM_JOOMDIET_RECIPE_SUBCATEGORY'); ?>:</b></label></td>
                    <td width="50%">
                        <select style="width: 100%;" type="text" name="recipe_subcategory" id="recipe_subcategory" value="" <?php if (!$this->categoryid) { echo 'disabled="disabled"'; } ?>>
                            <?php if ($this->categoryid) { ?>
                                <option value=0><?php echo JText::_('COM_JOOMDIET_ALL'); ?></option>
                                <?php foreach($this->subcategories as $category) { ?>
                                    <option value="<?php echo $category->id; ?>">
                                        <?php echo $category->name; ?>
                                    </option>
                                <?php } ?>
                            <?php } ?>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td width="50%" align="right"><label for="recipe_composition"><b><?php echo JText::_('COM_JOOMDIET_RECIPE_COMPOSITION')?>:</b></label></td>
                    <td width="50%">
                        <select style="width: 100%;" type="text" name="recipe_composition" id="recipe_composition" value="" >
                            <option value=0><?php echo JText::_('COM_JOOMDIET_ALL'); ?></option>
                            <?php foreach($this->variables as $variable) { ?>
                                <option value="<?php echo $variable->id; ?>">
                                    <?php echo $variable->name; ?>
                                </option>
                            <?php } ?>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td align="right"><a href="index.php?option=com_joomdiet&task=recipesearch"><?php echo JText::_('COM_JOOMDIET_BACK'); ?></a></td>
                </tr>
            <?php } else { ?>
                <tr>
                    <td></td>
                    <td align="right"><a href="index.php?option=com_joomdiet&task=recipesearch&advanced=true"><?php echo JText::_('COM_JOOMDIET_ADVANCED_SEARCH'); ?></a></td>
                </tr>
            <?php } ?>
                <tr>
                    <td align="center" colspan="2">
                        <input type="submit" value="<?php echo JText::_('COM_JOOMDIET_SEARCH'); ?>">
                    </td>
                </tr>
        </table>
    </div>
    
    <input type="hidden" name="option" value="com_joomdiet" />
    <input type="hidden" name="task" value="submitsearchrecipe" />
    <input type="hidden" name="boxchecked" value="0" />
    <input type="hidden" name="controller" value="recipesearch" />
    <input type="hidden" name="view" value="recipesearch" />
    <?php if ($this->advanced) { ?>
        <input type="hidden" name="advanced" value="true" />
    <?php } ?>
</form>
</div>
